home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/env python
- #Developed by Alberto Milone (aka tseliot)
-
- import sys
- import commands
- import string
- import os, popen2, fcntl, fcntl, select
- from os.path import isfile
- import shutil
- import objects, classes, main, idcardlist
-
- class Interface:
- #linetxt = ['-', '', ' Welcome to Envy ' + ver, ' ', 'Developed by Alberto Milone aka tseliot', '', '-']
- #def init(self):
- # self.linetxt = []
- def page(self):
- left_margin = 7
- border = ' ' * 4
- lines = []
- lenlinetxt = []
- for i in self.linetxt:#calculate the lenght of each element of linetxt and append them to lenlinetxt
- lenlinetxt.append(len(i))
-
- diffs = []
- diffspc = []
- it = 0#iterator
- it <= len(self.linetxt)#make sure it's not out of range
- for line in self.linetxt:
- maxlen = max(lenlinetxt)
- diffstmp = (maxlen - lenlinetxt[it]) / 2
- diffs.append(diffstmp)
- if it == 0 or it == len(self.linetxt)-1:#treat the 1st and the last line differently
- diffspctmp = '-' * diffs[it]#put -
- #rightmargin = '-' * (maxlen - (diffs[it] + lenlinetxt[it]) )
- rightmargin = '-' * (maxlen - lenlinetxt[it] )
- else:
- diffspctmp = ' ' * diffs[it]#put ' '
- #rightmargin = ' ' * (maxlen - (diffs[it] + lenlinetxt[it]) )
- rightmargin = ' ' * (maxlen - lenlinetxt[it] )
- diffspc.append(diffspctmp)
- genline = self.linetxt[it] + rightmargin #diffspc[it] +
- lines.append(genline)
- it += 1
-
- maxintlen = len(border)*2 + max(diffs)*2
- print '\n'
- print ' ' * left_margin + '+' + ('-' * len(border)) + lines[0] + ('-' * len(border)) + '+'#1st line
- for line in lines[1:-1]:
- print ' ' * left_margin + '|' + border + line + border + '|'# + '\n'
- print ' ' * left_margin + '+' + ('-' * len(border)) + lines[len(self.linetxt)-1] + ('-' * len(border)) + '+'#last line
- linetxt2 = []
- for l in lines:#calculate the lenght of each element of linetxt and append them to lenlinetxt
- linetxt2.append(len(l))
- def process(self):
- #NVIDIA INSTALLATION
- if self.operation == 'nvinstall':
- objects.nvinstconfirm()
- #NVIDIA UNINSTALLATION
- elif self.operation == 'nvuninstall':
- objects.nvuninstconfirm()
- #ATI INSTALLATION
- elif self.operation == 'atiinstall':
- objects.atiinstconfirm()
- #ATI UNINSTALLATION#
- elif self.operation == 'atiuninstall':
- objects.atiuninstconfirm()
- #MANUAL INSTALLATION
- elif self.operation == 'maninstall':
- objects.maninstconfirm()
- #NVIDIA CLEAN
- elif self.operation == 'nvidiaclean':
- objects.nvcleanconfirm()
- #RESTART THE XSERVER
- elif self.operation == 'xorgrestart':
- main.xserverstart()
- def confirm(self):
- while 1:
- choice = raw_input('Do you really want to ' + self.operation + ' the ' + self.brand + ' ? (Type either "yes" or "no")\n').strip()
- if choice.lower() == 'yes':
- self.gotoop#the operation to launch
- break
- elif choice.lower() == 'no':
- objects.mainmenu()
- break
-
-
- #class Confirmchoice:
- #def init():
- # self.operation = 'none'
- # self.brand = 'none'
- # self.gotoop = 'none'#the operation to launch
-
-
-
-
-